package com.stadium.service.impl;

import com.stadium.common.utils.SqlMapper;
import com.stadium.common.utils.UserUtils;
import com.stadium.dto.SysUserVerifaceDto;
import com.stadium.entity.SysUserVeriface;
import com.stadium.mapper.SysUserVerifaceMP;
import com.stadium.service.SysUserVerifaceSV;
import com.stadium.vo.SysUserVerifaceVo;
import com.stadium.vo.searchVo.SysUserVerifaceSearchVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;
import java.util.UUID;

@Service
@Transactional
public class SysUserVerifaceSVI implements SysUserVerifaceSV {
    @Autowired
    private SysUserVerifaceMP mapper;
    @Autowired
    private SqlMapper sqlMapper;

    @Override
    public List<SysUserVeriface> queryBySQL(String sql, Map<String, Object> map) {
        return sqlMapper.selectList(sql, map, SysUserVeriface.class);
    }

    @Override
    public void save(SysUserVerifaceVo sysUserVerifaceVo) {
        SysUserVeriface sysUserVeriface = new SysUserVeriface();
        BeanUtils.copyProperties(sysUserVerifaceVo, sysUserVeriface);
        String id = UUID.randomUUID().toString().replaceAll("-", "");
        sysUserVeriface.setCreateUser(UserUtils.getUserId());
        sysUserVeriface.setUpdateUser(UserUtils.getUserId());
        sysUserVeriface.setId(id);
        mapper.save(sysUserVeriface);
    }

    @Override
    public void update(SysUserVerifaceVo sysUserVerifaceVo) {
        SysUserVeriface sysUserVeriface = new SysUserVeriface();
        BeanUtils.copyProperties(sysUserVerifaceVo, sysUserVeriface);
        sysUserVeriface.setUpdateUser(UserUtils.getUserId());
        mapper.update(sysUserVeriface);
    }

    @Override
    public void saveBatch(List<SysUserVeriface> list) {
        mapper.saveBatch(list);
    }

    @Override
    public void delete(String id) {
        mapper.delete(id);
    }

    @Override
    public void deleteBatch(String[] ids) {
        mapper.deleteBatch(ids);
    }


    @Override
    public List<SysUserVerifaceDto> query(SysUserVerifaceSearchVo searchVo) {
        return mapper.query(searchVo);
    }

    @Override
    public SysUserVerifaceDto get(String id) {
        return mapper.get(id);
    }

    @Override
    public int getCount(SysUserVerifaceSearchVo searchVo) {
        return mapper.getCount(searchVo);
    }

    @Override
    public SysUserVerifaceDto getByUserId(String userId) {
        return mapper.getByUserId(userId);
    }
}
